/////////////////////////////////////////////////////////////////////////////
// Name:        ttsproperty.h
// Purpose:     Text to speech property classes
// Author:      Julian Smart
// Modified by:
// Created:     2009-02-14
// RCS-ID:      $Id$
// Copyright:   (c) Julian Smart
// Licence:   	
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_TTSPROPERTY_H_
#define _WX_TTSPROPERTY_H_

#include "wx/variant.h"

/* Use to give the subsequently-created properties a category name
 */

class wxTTSPropertyCategory
{
public:
    wxTTSPropertyCategory(const wxString& name = wxEmptyString)
    {
        m_oldCategory = sm_category;
        sm_category = name;
    }
    ~wxTTSPropertyCategory()
    {
        sm_category = m_oldCategory;
    }

    static void BeginCategory(const wxString& name)
    {
        sm_category = name;
    }

    static void EndCategory()
    {
        sm_category = wxEmptyString;
    }

    static wxString         sm_category;
    wxString                m_oldCategory;
};

/**
    @class wxTTSProperty
    
    @category{tts}
 */

class wxTTSProperty: public wxObject
{
    DECLARE_CLASS(wxTTSProperty)
public:
    wxTTSProperty()
    {
       m_show = TRUE;
        m_parentName = wxTTSPropertyCategory::sm_category;
    }

    wxTTSProperty(const wxTTSProperty& property) { Copy(property); }
    wxTTSProperty(const wxString& descr, const wxVariant& variant,
        const wxString& editorType = wxEmptyString,
        const wxString& groupName = wxEmptyString)
    {
        m_description = descr;
        m_variant = variant;
        m_editorType = editorType;
        m_groupName = groupName;
        m_show = TRUE;
        m_parentName = wxTTSPropertyCategory::sm_category;
    }

    wxTTSProperty(const wxString& name, const wxString& value = wxEmptyString)
    {
        m_variant.SetName(name);
        m_variant = value;
        m_show = TRUE;
    }

    void operator= (const wxTTSProperty& property) { Copy(property); }
    void Copy(const wxTTSProperty& property)
    {
        m_variant = property.m_variant;
        m_groupName = property.m_groupName;
        m_editorType = property.m_editorType;
        m_description = property.m_description;
        m_choices = property.m_choices;
        m_show = property.m_show;
        m_parentName = property.m_parentName;
        m_translatedName = property.m_translatedName;
    }

    bool operator== (const wxTTSProperty& property) const
    {
        return ((m_variant == property.m_variant) &&
            (m_groupName == property.m_groupName) &&
            (m_parentName == property.m_parentName) &&
            (m_editorType == property.m_editorType) &&
            (m_description == property.m_description) &&
            (m_show == property.m_show) &&
            (m_translatedName == property.m_translatedName) &&
            (m_choices == property.m_choices));
    }

    bool operator!= (const wxTTSProperty& property) const
    {
        return !((*this) == property);
    }

    inline const wxString& GetName() const { return m_variant.GetName(); }
    inline const wxString& GetParentName() const { return m_parentName; }
    inline wxString GetValue() const { return m_variant.GetString(); }
    inline wxVariant& GetVariant() { return m_variant; }
    inline const wxVariant& GetVariant() const { return m_variant; }
    inline const wxString& GetEditorType() const { return m_editorType; }
    inline const wxString& GetGroupName() const { return m_groupName; }
    inline const wxString GetCategory() const { return m_category; }
    inline const wxArrayString& GetChoices() const { return m_choices; }
    inline const wxString& GetDescription() const { return m_description; }
    
    inline void SetName(const wxString& name) { m_variant.SetName(name); }
    inline void SetParentName(const wxString& name) { m_parentName = name; }
    inline void SetValue(const wxString& value) { m_variant = value; }
    inline void SetValue(const wxVariant& value) { m_variant = value; }
    inline void SetEditorType(const wxString& type) { m_editorType = type; }
    inline void SetGroupName(const wxString& groupName) { m_groupName = groupName; }
    inline void SetCategory(const wxString& category) { m_category = category; }
    inline void SetChoices(const wxArrayString& choices) { m_choices = choices; }
    inline void SetDescription(const wxString& descr) { m_description = descr; }
    inline void Show(bool show) { m_show = show; }
    inline bool IsShown() const { return m_show; }

    // Get/set the visible translation, if any
    const wxString& GetTranslatedName() const { return m_translatedName; }
    void SetTranslatedName(const wxString& name) { m_translatedName = name; }

    // Get display name - translation if available, or actual
    wxString GetDisplayName() const { return m_translatedName.IsEmpty() ? GetName() : GetTranslatedName(); }

    // The name and value
    wxVariant   m_variant;

    // The visible translation, if any
    wxString    m_translatedName;

    // The editor type name (e.g. "file")
    // used to choose an editor.
    wxString    m_editorType;

    // The group name, e.g. window-style
    wxString    m_groupName;

    // The parent property name. Can be dot-separated if more than one.
    wxString    m_parentName;

    // Array of choices
    wxArrayString   m_choices;

    // Description
    wxString        m_description;

    // Category for this property
    wxString        m_category;

    // Whether to show or hide
    bool            m_show;
};

/**
    @class wxTTSProperties
    
    @category{tts}
 */

class wxTTSProperties: public wxObject
{
    DECLARE_CLASS(wxTTSProperties)
public:
    wxTTSProperties() {}
    wxTTSProperties(const wxTTSProperties& properties) { Copy(properties); }
    ~wxTTSProperties() { Clear(); }

    void operator = (const wxTTSProperties& properties) { Clear(); Copy(properties); }
    bool operator == (const wxTTSProperties& properties) ;
    void Copy(const wxTTSProperties& properties);

    inline const wxList& GetList() const { return m_list; }

    inline size_t GetCount() const { return m_list.GetCount(); }

    wxTTSProperty* AddProperty(wxTTSProperty* property, const wxString& insertAfter = wxEmptyString);
    void SetProperty(const wxTTSProperty& prop);
    void SetProperty(const wxString& name, const wxString& value);
    void SetProperty(const wxString& name, long value);
    void SetProperty(const wxString& name, int value) { SetProperty(name, (long) value); }
    void SetProperty(const wxString& name, double value);
    void SetProperty(const wxString& name, bool value);
    void SetProperty(const wxString& name, const wxVariant& value);
    void RemoveProperty(wxTTSProperty* property);
    void DeleteProperty(wxTTSProperty* property);
    void DeleteProperty(const wxString& name);
    void DeleteProperty(size_t i);
    wxTTSProperty* FindProperty(const wxString& name) const;
    wxTTSProperty* FindPropertyByDisplayName(const wxString& name);
    wxTTSProperty* FindOrCreateProperty(const wxString& name);
    wxString FindPropertyValueString(const wxString& name) const;
    bool FindPropertyValueBool(const wxString& name) const;
    long FindPropertyValueLong(const wxString& name) const;
    double FindPropertyValueDouble(const wxString& name) const;
    wxVariant FindPropertyValue(const wxString& name) const;
    wxTTSProperty* GetNth(int i) const;
    wxTTSProperty* GetProperty(int i) const { return GetNth(i); }
    
    void Clear();

private:
    wxList      m_list;
};

#endif
    // _WX_TTSPROPERTY_H_

